<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<meta name="keywords" content="jquery,ui,easy,easyui,web">
	<meta name="description" content="easyui help you build your web page easily!">
	<title>Expand row in DataGrid to show subgrid - jQuery EasyUI Demo</title>
	<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="http://www.jeasyui.com/easyui/demo/demo.css">
	<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
	<script type="text/javascript" src="http://www.jeasyui.com/easyui/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="http://www.jeasyui.com/easyui/datagrid-detailview.js"></script>
	<script type="text/javascript">

		$(function(){
			$('#dg').datagrid({
				view: detailview,
				detailFormatter:function(index,row){
					return '<div style="padding:2px"><table id="ddv-' + index + '"></table></div>';
				},
				onExpandRow: function(index,row){
					$('#ddv-'+index).datagrid({
						url:'detallado.php?numero_factura='+row.numero_factura,
						fitColumns:true,
						singleSelect:true,
						height:'auto',
						columns:[[
						
							{field:'codigo',title:'codigo',width:100},
							{field:'fecha_factura',title:'fecha_factura',width:100},
							{field:'codigo_producto',title:'codigo_producto',width:100},
							{field:'descripcion',title:'descripcion',width:100},
							{field:'cantidad',title:'cantidad',width:100},
							
							{field:'numero_factura',title:'Order ID',width:100}
							
						]],
						onResize:function(){
							$('#dg').datagrid('fixDetailRowHeight',index);
						},
						onLoadSuccess:function(){
							setTimeout(function(){
								$('#dg').datagrid('fixDetailRowHeight',index);
							},0);
						}
					});
					$('#dg').datagrid('fixDetailRowHeight',index);
				}
			});
		});
	</script>
</head>
<body>
	<h2>Expand row in DataGrid to show subgrid</h2>
	<div class="demo-info" style="margin-bottom:10px">
		<div class="demo-tip icon-tip">&nbsp;</div>
		<div>Click the expand button to expand row and view subgrid.</div>
	</div>
	
	<table id="dg" 
			url="encabezado.php" 
			title="DataGrid - SubGrid"
			singleSelect="true" fitColumns="true">
		<thead>
			<tr>
            <th field="codigo" width="60" align="center">codigo</th>
				<th field="numero_factura" width="80">Item ID</th>
				<th field="observacion" width="100">observacion</th>
				<th field="descuento" align="right" width="80">descuento</th>
				<th field="modalidad_cancelacion" align="right" width="80">modalidad_cancelacion</th>
				<th field="fecha_factura" width="220">fecha_factura</th>
				
			</tr>
		</thead>
	</table>
	
	
</body>
</html>